package fr.appliClient.client.widget;

import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.HasWidgets;

/**
 * @author remi implementation of callBack, in interaction with the view
 * @param <M>
 * @param <D>
 */
@SuppressWarnings("rawtypes")
public abstract class Presenter<M extends Model, D extends Display> implements PresenterCallBack {

	protected M model;

	protected D display;

	protected EventBus eventBus;

	public Presenter(EventBus eventBus, D display) {

		this.eventBus = eventBus;
		this.display = display;
	}

	/**
	 * First thing to do.
	 */
	protected abstract void bind();

	@SuppressWarnings("unchecked")
	protected void go(HasWidgets container) {

		bind();
		this.display.setPresenter(this);
		container.clear();
		container.add(this.display.asWidget());
	}

}
